//
//  ViewController.swift
//  HuaDaoPeifu
//
//  Created by Erickson on 16/3/28.
//  Copyright © 2016年 paiyipai. All rights reserved.
//

import UIKit

class ViewController: UITabBarController {

    
    override func viewDidLoad() {
        super.viewDidLoad()

        
        self.view.backgroundColor = UIColor.white
        let vc2 = UIStoryboard(name: "HDPayoutSb", bundle: nil)
        addChild(vc2, image: "shenqinglipei_un", selectedImage: "shenqinglipei", title: "申请理赔", identifier: "nav1")
        
        let vc1 = UIStoryboard(name: "HDArchiveSb", bundle: nil)
        addChild(vc1, image: "danganzhuizong_un", selectedImage: "danganzhuizong", title: "档案追踪", identifier: "nav2")
        
        let vc3 = UIStoryboard(name: "HDIndividualCenterSb", bundle: nil)
        addChild(vc3, image: "gerenzhongxin_un", selectedImage: "gerenzhongxin", title: "个人中心", identifier: "nav3")
        
    }
    
    
    func addChild(_ child: UIStoryboard,image:String,selectedImage:String,title:String,identifier:String) {
        
        
        let nav:UINavigationController =  child.instantiateViewController(withIdentifier: identifier) as! BaseNavigationController;
        let vc =  nav.childViewControllers.first!
        vc.title = title
//      vc.navigationItem.backBarButtonItem = UIBarButtonItem(image: UIImage(named: "back"), style: .Plain, target: nil, action: nil)

        vc.tabBarItem.image = UIImage(named: image)
        vc.tabBarItem.selectedImage = UIImage(named: selectedImage)?.withRenderingMode(.alwaysOriginal)
        self.addChildViewController(nav)
        
    }

    
   

}

